const crypto = require('crypto')

module.exports={
    decryptByAES:function(encryptedData,key,iv){
        encryptedData = Buffer.from(encryptedData,'base64')
        key = Buffer.from(key,'base64')
        iv = Buffer.from(iv,'base64')
        const decipher = crypto.createDecipheriv('aes-128-cbc',key,iv)
        let decrypted = decipher.update(encryptedData,'base64','utf8')
        decrypted += decipher.final('utf8')
        return decrypted
    },

    encryptSha1:function(data){
        return crypto.createHash('sha1').update(data,'utf8').digest('hex')
    }
}